ContextResultBuilder

Builds an organized set of context actions for use by a context handler. This is typically built in an upstream direction; that is to say a parent will request context with an empty builder, and then building will start with the most downstream ContextProvider child, with intermediate layers then building on that result before ending up with a completely built-up builder back at the call site.

Context builders organize context actions in two layers

  • group: a string id used to cluster like actions together. In most context menus, these can be seen by the "divider lines" present between context action categories (think of the copy/cut/paste section for example)

  • type: a ContextType key that marks which type of context this action is handling. This is mostly used for access to specific builders later, as the actual context event will simply be selecting an option from a context menu list.

  • NOTE: this builder uses linked maps, so the entry order of groups and types will define their visual ordering.

Author

fzzyhmstrs

Since

0.6.0

Parameters

position

Position position context. This should start as the general parent context as applicable, often the screen position and dimensions. Children may update this position with more scoped context.

Constructors

Link copied to clipboard
constructor(position: Position)

Types

Link copied to clipboard
object Companion

Common predefined group ids used by fzzy config. Group actions to these if you want context to appear alongside defaults from these groups.

Functions

Link copied to clipboard
fun add(group: String, type: ContextType, builder: ContextAction.Builder)

Adds a context action builder to this builder

Link copied to clipboard

Adds a collection of context action builders to this builder

Link copied to clipboard

Applies changes to an existing group of ContextAction.Builder if any in the given group exist in this builder. Does nothing if they do not exist.

Applies changes to an existing ContextAction.Builder if it exists in this builder. Does nothing if it does not exist.

Link copied to clipboard
fun move(operator: UnaryOperator<Position>)

Modifies this builders Position context. Generally this would be done to "scope in" position, say to a parent elements position and dimensions.